<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>

<script>
$(document).ready(function(){
	parent.$.messager.progress('close'); 	
	loadResult();
	clearSingleBrand();
});

/**
 *校验上传文件
 */
function checkFile(file){
	var checkResult = true;
	if(file == ""){
		$.messager.alert('提示','文件为空,请上传文件后再提交','warning');
		checkResult = false;
		return;
	}
	var index = file.indexOf(".");
	var suffix = file.substring(index+1,file.length);
	if(suffix != "xls"){
		$.messager.alert('提示','文件格式不对,请输入.xls格式文件','warning');
		checkResult = false;
	}
	return checkResult;
}

function save(){	
	if ($("#yearId").combobox('getValue') == "" || $("#yearId").combobox('getValue') == "0"){
		$.messager.alert('提示','年份不能为空','warning');
	}else if ($("#quarter_ID").combobox('getValue') == "" || $("#quarter_ID").combobox('getValue') == "0"){
		$.messager.alert('提示','季度不能为空','warning');
	}else if ($("#single_brand_ID").val() == "" || $("#single_brand_ID").val() == "0"){
		$.messager.alert('提示','品牌不能为空','warning');
	}
	var file = $("#inventory").textbox('getValue');
	if(checkFile(file)){
		$('#insertRandom').val(Math.random());
    	document.barcodeInsertForm.action="productJSPAction!batchInsertBarcode";
    	document.barcodeInsertForm.submit();
    	$.messager.progress({
    	    title:'请稍候',
    	    msg:'数据加载中...'
    	});
    	
	}	
}

function batchDelete(){
	var file = $("#deleteInventory").textbox('getValue');
	if(checkFile(file)){
		$('#deleteRandom').val(Math.random());
	    document.barcodeDeleteForm.action="productJSPAction!batchDeleteBarcode";
	    document.barcodeDeleteForm.submit();
	    $.messager.progress({
		    title:'请稍候',
		    msg:'数据加载中...'
		});
	}
}
function batchUpdate(){
	var file = $("#updateInventory").textbox('getValue');
	if(checkFile(file)){
		$('#updateRandom').val(Math.random());
	    document.barcodeUpdateForm.action="productJSPAction!batchUpdateBarcode";
	    document.barcodeUpdateForm.submit();
	    $.messager.progress({
		    title:'请稍候',
		    msg:'数据加载中...'
		});	
	}
}


</script>
</head>
<body>


<div class="easyui-layout" data-options="fit : true,border : false">
<%@ include file="../common/JRComponent.jsp"%>
	<div data-options="region:'north',border:false" style="height: 105px;">
	<s:form id="" name=""
		theme="simple" method="POST">
		<table width="95%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td height="50" colspan="7">
								
								<table width="100%" border="0">
									<tr class="PBAOuterTableTitale">
										<td height="51" colspan="6">总部批量编辑条码:<br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
										<span style="font-size:11px;color:red">注意：所有上传文件格式必须为 .xls</span>
											
										</td>
									</tr>								
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</s:form>
	</div>
	
	<div data-options="region:'center',border:false">
	<s:form action="/action/productJSPAction!batchInsertBarcode"
		method="POST" name="barcodeInsertForm" id="barcodeInsertForm"
		enctype="multipart/form-data" theme="simple">

		<table width="95%" align="center" class="OuterTable">
			<tr>
				<td>	
				
					<table width="100%" align="left" border="0">
						<tr class="PBAOuterTableTitale" align="left">
							<th colspan="6">新增:								
							</th>
						</tr>
						<tr class="InnerTableContent">
							<td width="5%" height="40"><input type="hidden" id="insertRandom" name="formBean.random"></td>
							<td width="12%" height="40">年份：<s:select  cssClass="easyui-combobox" style="width:150px"
									name="formBean.productBarcode.product.year.year_ID" size="1"
									id="yearId" list="uiBean.basicData.yearList" listKey="year_ID"
									listValue="year" /></td>
							
							<td width="12%">季度:<s:select  cssClass="easyui-combobox" style="width:150px"
									name="formBean.productBarcode.product.quarter.quarter_ID"
									size="1" id="quarter_ID" list="uiBean.basicData.quarterList"
									listKey="quarter_ID" listValue="quarter_Name" /></td>
							<td width="18%">品牌:<%@ include file="../common/SingleBrandInput.jsp"%></td>
							<td width="17%"><input class="easyui-filebox" id="inventory"  name="formBean.inventory" data-options="prompt:'请上传新增条码文件',buttonText: '条码文件',buttonAlign: 'left'" style="width:90%"> </td>
							<td align='left'><a  href="#" class="easyui-linkbutton c8"  style="width:110px;" onclick="save();" >新增</a></td>
						</tr>


					</table>

				</td>
			</tr>
		</table>

	</s:form>
	
	</div>
	
		<div data-options="region:'center',border:false" style="position: relative;top: 210px;">
				<s:form action="/action/productJSPAction!batchUpdateBarcode"
		method="POST" name="barcodeUpdateForm" id="barcodeUpdateForm"
		enctype="multipart/form-data" theme="simple">

		<table width="95%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" align="left" border="0">
						<tr class="PBAOuterTableTitale" align="left">
							<th colspan="3">修改:
							</th>
						</tr>
						<tr class="InnerTableContent">
							<td width="5%"><input type="hidden" id="updateRandom" name="formBean.random"></input></td>
							<td width="20%" height="40"><input class="easyui-filebox" id="updateInventory"  name="formBean.inventory" data-options="prompt:'请上传更新条码文件',buttonText: '条码文件',buttonAlign: 'left'" style="width:90%"> </td>
							<td>
								<a href="#" class="easyui-linkbutton c8" style="width:7%" onclick="batchUpdate();" >更新</a>
							</td>
						</tr>

					</table>
				</td>
			</tr>
		</table>
	</s:form>
		</div>
		
				<div data-options="region:'center',border:false" style="position: relative;top: 240px;">
				<s:form action="/action/productJSPAction!batchDeleteBarcode"
		method="POST" name="barcodeDeleteForm" id="barcodeDeleteForm"
		enctype="multipart/form-data" theme="simple">

		<table width="95%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" align="left" border="0">
						<tr class="PBAOuterTableTitale" align="left">
							<th colspan="3">删除:
							</th>
						</tr>
						<tr class="InnerTableContent">
							<td width="5%"><input type="hidden" id="deleteRandom" name="formBean.random"></td>
							<td width="20%" height="40"><input class="easyui-filebox" id="deleteInventory"  name="formBean.inventory" data-options="prompt:'请上传删除条码文件',buttonText: '条码文件',buttonAlign: 'left'" style="width:90%"> </td>
							<td>
								<a href="#" class="easyui-linkbutton c8" style="width:7%"  onclick="batchDelete();" >删除</a>
							</td>
						</tr>

					</table>
				</td>
			</tr>
		</table>
	</s:form>
		</div>
</div>

</body>
</html>